import React, {Component, createRef} from 'react';
//受控组件
class ControlledComponents extends Component {
    myUserName=createRef();
    state={
        value:'UN'
    }
    render() {
        return (
            <div>
                <div>登录页</div>
                <input type={"text"} ref={this.myUserName} value={this.state.value} onChange={(event)=>{
                    let value=event.target.value;
                    console.log("aaa")
                    this.setState({
                        value:value
                    })
                }}/>
                <button onClick={()=>{
                    console.log(this.myUserName.current.value)
                }}>登录</button>
                <button  onClick={()=>{
                    this.myUserName.current.value="";
                }}>重置</button>
            </div>
        );
    }
}

export default  ControlledComponents;
